#ifndef GAME_H
#define GAME_H

#include <iostream>
#include <vector>
#include<cmath>
#include <algorithm>
#include <time.h>
#include <string>
#include "movables.h"
#include "map.h"
#include "global_variables.h"


using namespace std;

enum Rules{CAN_MOVE, CANT_MOVE, DEATH_TO_DIGDUG, DEATH_TO_MONSTER, DEATH_TO_PROJECTILE, CAN_OVERLAP};
enum Move_result{HAS_MOVED, CANNOT_MOVE, OBJECT_DEAD, GAME_OVER};

class Game
{
public:

	Game ();
	Game_result update(Action instruction);
	
	Movables get_movable (Movable_type type, int vector_count);
	Map get_map();
	int count; 
	string enum_to_string(Direction t);
	string enum_to_string(Move_result t);
	
	void print_monsters(vector<Movables> &monsters);
	//Make these private later on!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	vector< Movables > _monsters;
	Movables _digdug;
	Movables _projectile;

	Move_result move(Movables& movable, Direction direction);
	Rules get_rule(Movable_type object_type, Movable_type map_location_type);
	vector <Direction> get_valid_directions(int x, int y, Movables &movable);
	bool contains(vector<Direction> list, Direction value);
	bool contains(vector<int> &list, int search_item);

	clock_t start_time, end_time; 
		
	bool _is_shooting;


private:
	
	Map _map;
	
	
	//vector< Movables > _projectiles;

	
	Direction get_direction(Movables &monster, Movables &digdug);

	

	void generate_objects();	
	void generate_map();
	
	void route_monsters(vector<Movables> &monsters, Movables &digdug);



	bool opposite(Direction dir);
	bool update_list_co_ordinates (vector<vector<int>> & x_co_ordinates, vector<vector <int>> & y_co_ordinates, int list_no,  Direction dir);
	void monster_directions_update(vector<int> & x_co_ordinates, vector <int> & y_co_ordinates); 
	
	Direction get_monster_move_direction(Movables &monster);

	//Used to move monsters in disembodied state
	void move_disembodied_monster(Movables &monster, Movables& const digdug);
	vector<int> _disembodied_end_pos;

	vector <Direction> remove_backwards_direction(vector<int> x_cord, vector<int> y_cord, Direction direction);


};

#endif